﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DTGroup_ZheJiang.Models;
using DTGroup_ZheJiang.Business;
using DTGroup.Networking.Framework.Utils;

namespace DTGroup_ZheJiang.WebUI.ashx
{
    /// <summary>
    /// Common 的摘要说明
    /// </summary>
    public class Common : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string userName = DTGroup.Networking.Framework.Utils.Web.RequestUtil.GetString("userName", DTGroup.Networking.Framework.Utils.Web.Method.Post, string.Empty);
            string userPwd = DTGroup.Networking.Framework.Utils.Web.RequestUtil.GetString("userPwd", DTGroup.Networking.Framework.Utils.Web.Method.Post, string.Empty);
            string Options = DTGroup.Networking.Framework.Utils.Web.RequestUtil.GetString("Options", DTGroup.Networking.Framework.Utils.Web.Method.Post, string.Empty);
            if (Options == "UserLogin")
            {
                UserLogin(context, userName, userPwd);
            }
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="userPwd"></param>
        public void UserLogin(HttpContext context, string userName, string userPwd)
        {
            User u = UserBO.Login(userName, userPwd);
            if (u != null)
            {
                context.Response.Redirect("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}